<template>
  <div class="song-sheet">
    <div class="song-sheet-left">
      <ul class="song-sheet-nav">
        <li
          v-on:click="change(item.name, index)"
          :class="currentIndex == index ? 'song-bg' : 'song-sheet-li'"
          v-for="(item, index) in SongSheetSort"
          :key="item.name"
        >
          {{ item.name }}
        </li>
      </ul>
    </div>
    <div class="sst">
      <div
        class="song-sheet-right"
        v-for="song in SongList.playlists"
        :key="song.id"
      >
        <div class="img-shadow">
          <img :src="song.coverImgUrl" class="song-sheet-img" />
        </div>
        <div class="song-sheet-detailed">
          <div class="detailed-header">
            <a class="detailed-title">{{ song.name }}</a>
            <div class="detailed-producer">
              制作人：{{ song.creator.nickname }}
            </div>
          </div>
          <div class="detailed-content">
            {{ song.description }}
          </div>
          <div class="detailed-btn">
            <button class="iconfont icon-24gl-play btn-play" @click="GoPlayer">
              播放全部
            </button>
            <button class="iconfont icon-fenxiang btn-share" @click="ShowShare">
              分享
            </button>
          </div>
        </div>
      </div>
    </div>

    <div class="cool-dog-share" v-if="isShareShow">
      <div class="share-heard">
        <span class="share-song">分享歌曲</span>
        <span class="del-share" @click="closeShare">X</span>
      </div>
      <div class="share-body">
        <div class="share-img">
          <img src="./images/share_weixin.png" class="wx" />
          <span class="img-content">微信</span>
        </div>
        <div class="share-img">
          <img src="./images/share_qq.png" />
          <span class="img-content">QQ好友</span>
        </div>
        <div class="share-img">
          <img src="./images/share_qqspace.png" />
          <span class="img-content">QQ空间</span>
        </div>
        <div class="share-img">
          <img src="./images/share_weibo.png" />
          <span class="img-content">新浪微博</span>
        </div>
      </div>
    </div>

    <MusicPlayer v-if="isShowPlayer" />
  </div>
</template>

<script>
import { reqSongSheetList, reqSongSheet } from "@/api/index";
import MusicPlayer from "@/components/MusicPlayer/index";
export default {
  name: "SongSheet",
  data() {
    return {
      isShareShow: false,
      isShowPlayer: false,
      currentIndex: 0,
      SongSheetSort: [],
      SongList: [],
    };
  },
  components: {
    MusicPlayer,
  },
  methods: {
    change: function (name, index) {
      this.currentIndex = index;
      this.getSongSheet(10, name);
      // console.log(this.SongList.playlists);
    },
    // 关闭分享
    closeShare() {
      this.isShareShow = false;
    },
    // 显示分享
    ShowShare() {
      this.isShareShow = true;
      // console.log(this.SongSheetSort);
    },
    // 获取分类
    async getSongSheetList() {
      const res = await reqSongSheetList();
      // console.log(res, "11");
      const sub = res.sub.map((item) => {
        return {
          name: item.name,
        };
      });
      this.SongSheetSort = sub.slice(3, 7);
    },

    // 获取歌单
    async getSongSheet(limit, tag) {
      const res = await reqSongSheet(limit, tag);
      this.SongList = res;
    },
    GoPlayer() {
      this.$router.push({
        name: "PlayerKugou",
      });
    },
  },
  mounted() {
    this.getSongSheetList();
    this.getSongSheet();
  },
};
</script>

<style scoped>
.song-sheet {
  display: flex;
  justify-content: center;
  position: relative;
}
.song-sheet-left {
  width: 210px;
  height: 198px;
  /* background: greenyellow; */
  margin-top: 30px;
  display: flex;
}
.song-sheet-nav {
  list-style: none;
  padding: 0;
}
.song-sheet-li {
  height: 36px;
  width: 210px;
  align-items: center;
  background: #fff;
  color: #000;
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  line-height: 36px;
  left: 50%;
  font-size: 14px;
}
.song-bg {
  height: 36px;
  width: 210px;
  align-items: center;
  background: #169af3;
  color: #fff;
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  line-height: 36px;
  left: 50%;
  font-size: 14px;
}
.song-sheet-li:hover {
  background: #169af3;
  color: #fff;
  cursor: pointer;
}

.song-sheet-right {
  width: 770px;
  height: 116px;
  display: flex;
  margin-top: 20px;
  margin-left: 20px;
  border-bottom: 1px solid #dcdcdc;
}
.img-shadow {
  width: 100px;
  height: 100px;
  margin-right: 10px;
  border: 2px solid #fff;
  /* box-shadow: 1px 1px 1px #8e8e8e inset, 1px -1px 1px #8e8e8e inset,
    -1px 1px 1px #8e8e8e, -1px -1px 1px #8e8e8e; */
  box-shadow: 0 0 5px #8e8e8e;
}
.img-shadow:hover {
  border: 2px solid #169af3;
}
.song-sheet-img {
  width: 100%;
  height: 100%;
}
.song-sheet-detailed {
  height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.detailed-header {
  display: flex;
  justify-content: space-between;
  width: 650px;
}
.detailed-title {
  font-size: 14px;
}
.detailed-title:hover {
  color: #169af3;
  cursor: pointer;
}
.detailed-producer {
  font-size: 12px;
}
.detailed-content {
  font-size: 12px;
  color: #999;
  margin-bottom: 5px;
  margin-top: 15px;
  line-height: 150%;
  height: 40px;
  width: 640px;
  /* border: 1px solid red; */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.btn-play {
  background: #169af3;
  border: 0;
  font-size: 12px;
  padding: 5px 25px;
  color: #fff;
  margin-right: 20px;
}
.btn-share {
  background: #169af3;
  border: 0;
  font-size: 12px;
  padding: 5px 25px;
  color: #fff;
}
.btn-play:hover {
  background: #2073aa;
}
.btn-share:hover {
  background: #2073aa;
}
.sst {
  height: 100%;
}

.cool-dog-share {
  height: 308px;
  width: 476px;
  /* border: 1px solid red; */
  background: #fff;
  position: absolute;
}
.share-heard {
  height: 36.5px;
  line-height: 36.5px;
  font-size: 14px;
  width: 475px;
  background: #2a323b;
  color: #fff;
  display: flex;
  justify-content: space-between;
}
.share-song {
  padding-left: 15px;
}
.del-share {
  padding-right: 15px;
}
.share-body {
  display: flex;
  justify-content: space-evenly;
  padding-top: 70px;
}
.share-img {
  /* border: 1px solid red; */
  display: flex;
  flex-direction: column;
  align-items: center;
}
.img-content {
  padding-top: 5px;
}
</style>
